const app = getApp()
Page({
  data: {
    isManage:false,
    bank: {
      money: 0,
      lack_money: 0,
      save_money: 0,
      income_money: 0,
      shop_money: 0
    },
    config:{},
  },
  //监听页面初次载入完成
  onLoad: function (options) {
    app.getParam(options);
  },
  //生命周期函数--监听页面显示
  onShow: function () {
    app.loginState((state)=>{
      this.setData({
        loginstate:state,
        ucode:state ? app.globalData.loginuser.ucode:'',
      })
    })
    app.appConfig((rel)=>{
      this.setData({config:rel})
    });
  },
  //拨打电话
  callPhone:function (e) {
    app.callPhone(e);
  },
  //进入商圈
  onMonay: function () {
    wx.navigateTo({
      url: '../group/index',
    })
  },
 //进入账单
  onBill: function () {
    wx.navigateTo({
      url: '../bank/index',
    })
  },
  //进入账单
  onPhone: function () {
    wx.navigateTo({
      url: '../helper/bindphone',
    })
  }, 
  //一键复制事件
  copyBtn: function () {
    wx.setClipboardData({
      data: '开通会员填写我的邀请码【 ' + app.globalData.loginuser.ucode +' 】和我一起省钱,还能赚钱.',
      success:(res) =>{
        wx.showToast({
          title: '复制成功',
        });
      }
    });
  },
  onLoginState: function (e) {
    if(e.detail.state == true){
      app.appConfig((rel)=>{
        this.setData({
          config: rel,
          loginstate:true,
          ucode:app.globalData.loginuser.ucode,
        })
        if(app.util().isNull(rel.user_bindphone)){
          wx.navigateTo({
            url: '../helper/bindphone',
          })
        }
      });
    }
  },
  onLogin: function () {
    this.setData({
      loginstate:false,
    })
  },
  //转发
  onShareAppMessage: function (res) {
    return {
      title: app.globalData.appConfig.shore_text,
      path: '/page/index?ucode='+app.globalData.ucode
    }
  }
})